﻿using SpreadsheetGear;
using SpreadsheetGear.Commands;

namespace DesignerHelper.Commands
{
    public class CopySheet : Command
    {
        public CopySheet(IWorksheet worksheet, bool copyBefore) : base(worksheet.Workbook)
        {
            Worksheet = worksheet;
            CopyBefore = copyBefore;
        }

        private IWorksheet Worksheet { get; set; }
        private bool CopyBefore { get; set; }
        protected override bool Execute()
        {
            ISheet sheet = CopyBefore ? Worksheet.CopyBefore(Worksheet) : Worksheet.CopyAfter(Worksheet);
            return true;
        }

        public override string DisplayText => "复制工作表";

        public override CommandUndoSupport UndoSupport => CommandUndoSupport.None;
    }
}
